package org.liubility.robot;

import cc.moecraft.icq.PicqBotX;
import cc.moecraft.icq.PicqConfig;
import cc.moecraft.icq.event.EventHandler;
import cc.moecraft.icq.event.IcqListener;
import cc.moecraft.icq.event.events.message.EventPrivateMessage;
import com.jdragon.common.json.JsonUtils;

/**
 * @Author: Jdragon
 * @email: 1061917196@qq.com
 * @Date: 2020.09.02 16:13
 * @Description:
 */
public class App {
    public static void main(String[] args) {
        // 创建机器人对象 ( 传入配置 )
        PicqBotX bot = new PicqBotX(new PicqConfig(9999).setDebug(true));

        // 添加一个机器人账户 ( 名字, 发送URL, 发送端口 )
        bot.addAccount("Bot01", "127.0.0.1", 5700);

        bot.getEventManager().registerListener(new MyListener());

        // 启动机器人, 不会占用主线程
        bot.startBot();
    }
    static class MyListener extends IcqListener {
        @EventHandler
        public void test(EventPrivateMessage event){
            System.out.println(JsonUtils.object2Str(event));
            event.respond(event.getMessage());
        }
    }
}
